<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <script>
        document.getElementsByTagName('html')[0].style.fontSize = '15px'
    </script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="./css/common.css">
    <link rel="stylesheet" href="./css/icon.css">
    <link rel="stylesheet" href="./css/mint.min.css">
    <title>检验报告</title>
</head>
<body>
<div class="bgcolor" id="app">
    <div class="page-navbar">
        <mt-navbar class="page-part fixed flexHC" v-model="selected">
            <template v-for="(itm,idx)  in opListTab">
                <mt-tab-item :id="idx">
                    <div class="font15">{{itm}}</div>
                </mt-tab-item>
            </template>
        </mt-navbar>
        <mt-tab-container v-model="selected">
            <template v-for="(itm,idx) in opListTab">
                <mt-tab-container-item class="marginT50" :id="idx">
                    <div v-for="(itm2,idx2) in opList[idx]"
                         :key="itm2.bedCode+idx2"
                         @click="onItemClick(itm2.episodeId,(itm2.bedCode == '' ? '未分床' : itm2.bedCode)+'   '+itm2.name)"
                         class="bgwhite padding8 margin5 radius5">
                        <div class="flexHL">
                            <div class="font14 fontBold marginT5">{{itm2.bedCode == "" ? "未分床" : itm2.bedCode}}</div>
                            <div class="flexHR flexG">
                                <div class="padding5 radiusTRBL5 colorwhite center font14Bold marginR10"
                                     :style="getLevelColor(itm2.careLevel)">{{itm2.careLevel.replace("护理", "")}}
                                </div>
                            </div>
                        </div>
                        <div class="flexHL marginT10">
                            <div class="font17 fontBold marginT5">{{itm2.name}}</div>
                            <div v-if="itm2.sex=='男'" class="width20 height20 base64_ic_sex_male marginL20"></div>
                            <div v-if="itm2.sex=='女'" class="width20 height20 base64_ic_sex_female marginL20"></div>
                            <div class="flexHR flexG">
                                <div v-if="itm2.newPatient=='1'"
                                     class="width20 height20 radius5 colorwhite center font14 marginR10"
                                     style="background: #E066FF">入
                                </div>
                                <div v-if="itm2.operation=='1'"
                                     class="width20 height20 radius5 colorwhite center font14 marginR10"
                                     style="background: #73C2F1">术
                                </div>
                                <div v-if="itm2.illState=='病重'"
                                     class="width20 height20 radius5 colorwhite center font14 marginR10"
                                     style="background: #F11F39">重
                                </div>
                                <div v-if="itm2.illState=='病危'"
                                     class="width20 height20 radius5 colorwhite center font14 marginR10"
                                     style="background: #F11F39">危
                                </div>
                                <div v-if="itm2.arreag=='1'"
                                     class="width20 height20 radius5 colorwhite center font14 marginR10"
                                     style="background: #FFC33C">欠
                                </div>
                                <div v-if="itm2.criticalValue=='1'"
                                     class="width20 height20 radius5 colorwhite center font14 marginR10"
                                     style="background: #FF8154">急
                                </div>
                                <div v-if="itm2.gotAllergy=='1'"
                                     class="width20 height20 radius5 colorwhite center font14 marginR10"
                                     style="background: #50E3C2">敏
                                </div>
                                <div v-if="itm2.fever=='1'"
                                     class="width20 height20 radius5 colorwhite center font14 marginR10"
                                     style="background: #FF818D">热
                                </div>
                                <div v-if="itm2.epdReport=='1'"
                                     class="width20 height20 base64_ic_epd_report marginR10"></div>
                                <div v-if="itm2.epdNotReport=='1'"
                                     class="width20 height20 base64_ic_epd_noreport marginR10"></div>
                            </div>
                        </div>
                    </div>
                </mt-tab-container-item>
            </template>
        </mt-tab-container>
    </div>

</div>
</body>
<!-- 先引入 Vue -->
<script src="js/vue.min.js"></script>
<!-- 引入组件库 -->
<script src="js/mint.min.js"></script>
<!--web请求-->
<script src="js/webservice.js"></script>
<script>
    var tag = ""
    var tUserId = "1885";
    var tLocId = "8";
    var tWardId = "3";
    function getString(s) {
        if (tag == "USERID") {
            tUserId = s;
            getSPString("LOCID") //第2个调用
        } else if (tag == "LOCID") {
            tLocId = s;
            getSPString("WARDID") //第3个调用
        } else if (tag == "WARDID") {
            tWardId = s;
        }
    }
    function getSPString(key) {
        if (window.android) {
            tag = key;
            window.android.callAndroid("com.blankj.utilcode.util.SPStaticUtils:getString(" + key + ")", "call");
        }
    }
    //第1个调用
    getSPString("USERID")

    //添加鸿蒙 传递用户信息
    window.addEventListener('message', function (event) {
        if (event.data === 'init_web_messageport') {
            if (event.ports[0] != null) {
                h5Port = event.ports[0]; // 1. 保存从ets侧发送过来的端口
                h5Port.onmessage = function (event) {
                    var result = event.data;// 2. 接收ets侧发送过来的消息.
                    console.log("In html got message, result: ", (result));
                    if (typeof (result) == "string") {
                        //固定格式：hospitalId,groupId,wardId,userId,locId
                        var arr = result.split(",");
                        tHospitalId = arr[0];
                        tGroupId = arr[1];
                        tWardId = arr[2];
                        tUserId = arr[3];
                        tLocId = arr[4];
                        var txt = tHospitalId + "-" + tGroupId + "-" + tWardId + "-" + tUserId + "-" + tLocId
                        //document.getElementById("msg").innerHTML = "String:" + result + "=" + txt
                        initVue();
                    }
                }
            }
        }
    })

    function initVue() {
        new Vue({
            el: '#app',
            data: {
                selected: "1",
                inBedAllList: [],
                manageInBedList: [],
                waitList: [],
                selected: 0,
                opList: [],
                opListTab: ["在床", "所管区", "等待区"],
            },
            mounted() {
                //将要给原生调用的方法挂载到 window 上面
                window.Config = this.Config
                window.getScanMsg = this.getScanMsg
                window.GetInWardPatList = this.GetInWardPatList
                this.initData()
            },
            methods: {
                //获取扫码
                getScanMsg(scanInfo) {
                    this.$toast(scanInfo)
                },
                GetInWardPatList(data) {
                    Http.hideLoading(this)
                    var patInfoList = data.patInfoList
                    for (let i = 0; i < patInfoList.length; i++) {
                        if (patInfoList[i].inBedAll == "1") {
                            this.inBedAllList.push(patInfoList[i])
                        }
                        if (patInfoList[i].manageInBed == "1") {
                            this.manageInBedList.push(patInfoList[i])
                        }
                        if (patInfoList[i].wait == "1") {
                            this.waitList.push(patInfoList[i])
                        }
                    }
                    this.opList.push(this.inBedAllList)
                    this.opList.push(this.manageInBedList)
                    this.opList.push(this.waitList)
                },
                initData() {
                    var params = {
                        wardId: tWardId,
                        userId: tUserId,
                    }
                    Http.showLoading(this)
                    Http.postPlus("GetInWardPatList", params, (data) => {
                        console.log(data)
                        this.GetInWardPatList(data);
                    })
                },
                getLevelColor(level) {
                    if (level.indexOf("特级") !== -1) return 'background: #FF0000'
                    if (level.indexOf("一级") !== -1) return 'background: #E066FF'
                    if (level.indexOf("二级") !== -1) return 'background: #4C95EF'
                    return ''
                },
                onItemClick(episodeId, patmsg) {
                    console.log(episodeId)
                    if (window.android) {
                        var key = "http://10.1.20.152:1443/pda/LabResultListFragment.html?episodeId=" + episodeId + "&patmsg=" + patmsg;
                        window.android.callAndroid("com.base.commlibs.view.WebActivity:startActivity(" + key + ")", "call");
                    } else {
                        window.location.href = "LabResultListFragment.html?episodeId=" + episodeId + "&patmsg=" + patmsg;
                    }
                    // window.open('LabResultListFragment.html?episodeId='+episodeId+'&patmsg='+patmsg, "_blank")
                }
            }
        })
    }

    var ua = navigator.userAgent
    if (ua.includes("OpenHarmony") || ua.includes("Linux")) {
        //鸿蒙不处理
    } else if (ua.includes("Mozilla") || ua.includes("AppleWebKit") || ua.includes("Safari") || ua.includes("Chrome") || ua.includes("Edg")) {
        initVue() //浏览器 直接打开
    }
</script>

</html>